
package com.example.paper.TestMigration;


import com.example.paper.common.datam.service.impl.UserStuent2Service;
import com.example.paper.common.datam.userStudentJob.UserStudentJob;
import com.example.paper.common.entity.UserStudent2;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * 数据移植使用案例，通过UserStudent往UserStudent2移植
 */
@Slf4j
@Service
public class TestMigration implements ApplicationRunner {

    @Autowired
    private UserStudentJob userStudentJob;

    @Autowired
    private UserStuent2Service userStuent2Service;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        List<UserStudent2> list = userStuent2Service.list();
        log.info("移植前：{}条", list.size());

        HashMap<String, Object> map = new HashMap<>();
        // 不设置具体参数，即为全表移植，增加查询条件需要自行设置参数
        userStudentJob.doJob(map);

        List<UserStudent2> list2 = userStuent2Service.list();
        log.info("移植后：{}条", list2.size());
    }

}
